import { Column, CreateDateColumn, Entity, JoinColumn, ManyToMany, PrimaryGeneratedColumn } from "typeorm";
import { Goods } from "src/module/grocery/entities/goods.entity";

@Entity('product_cart', { schema: 'shop' })
export class CartEntity {
	constructor(partial: Partial<CartEntity>) {
		Object.assign(this, partial);
	}

	@PrimaryGeneratedColumn()
	id: number

	@Column('int', { name: 'user_id', comment: '用户id' })
	userId: number

	@ManyToMany(() => Goods)
	@JoinColumn({ name: 'product_id' })
	product: Goods

	@Column('int', { name: 'specs_id', comment: '规格id' })
	specsId: number

	@Column('tinyint', { comment: '当前规格数量' })
	sum: number

	@CreateDateColumn({ name: 'create_tiem', comment: '加购时间' })
	createTime: Date
}
